using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
    public class tbtrangthaiBUS
    {
        public static void Insert(tbtrangthaiDTO tt)
        {
            tbtrangthaiDAL tbtrangthaiDAL = new tbtrangthaiDAL();
            tbtrangthaiDAL.Insert(tt);
        }
        public static void Update(tbtrangthaiDTO tt)
        {
            tbtrangthaiDAL tbtrangthaiDAL = new tbtrangthaiDAL();
            tbtrangthaiDAL.Update(tt);
        }
        public static void Delete(int iD)
        {
            tbtrangthaiDAL tbtrangthaiDAL = new tbtrangthaiDAL();
            tbtrangthaiDAL.Delete(iD);
        }
        public static tbtrangthaiDTOColection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            tbtrangthaiDAL tbtrangthaiDAL = new tbtrangthaiDAL();
            return tbtrangthaiDAL.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
        public static tbtrangthaiDTO GetByID(int iD)
        {
            int t = 0;
            tbtrangthaiDAL tbtrangthaiDAL = new tbtrangthaiDAL();
            tbtrangthaiDTOColection ttcolect = tbtrangthaiDAL.GET("where " + tbtrangthaiDTOColumn.Matrangthai.ToString() + " = " + iD.ToString(), 0, 0,
                tbtrangthaiDTOColumn.Tentrangthai.ToString(), "ASC", out t);
            if (ttcolect.Count >= 1)
                return ttcolect[0];
            return null;
        }
        public static tbtrangthaiDTOColection GETAll()
        {
            int t = 0;
            tbtrangthaiDAL tbtrangthaiDAL = new tbtrangthaiDAL();
            return tbtrangthaiDAL.GET("where 1=1", 0, 10, tbtrangthaiDTOColumn.Tentrangthai.ToString(), "ASC", out t);
        }
    }
}
